package src.reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        Method method = cls.getMethod("say",String.class);//say(String info)
        method.invoke(obj,"哈哈哈");//obj.say("哈哈哈")

        Method method2 = cls.getMethod("say",String.class,int.class);
        method2.invoke(obj,"嘿嘿",5);

    }
}
